package com.tledu.zyf.servlet.group;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.tledu.zyf.model.Group;
import com.tledu.zyf.service.IGroupService;
import com.tledu.zyf.util.ForwardUtil;
import com.tledu.zyf.util.ObjectFactory;

@WebServlet("/group/list")
public class GroupListServlet extends HttpServlet {
	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// 获取 GroupService 对象
		IGroupService groupService = ObjectFactory.getGroupService();

		// 调用 list 方法,获取所有的部门数据
		List<Group> groups = groupService.list();

		// 传递到页面
		request.setAttribute("groups", groups);

		// 跳转到对应的展示页面
		// 封装好的工具类写法
		ForwardUtil.forward(request, response, "group/list");
	}
}
